from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from django.apps import apps
# 设置环境变量
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tdesign_media_crawler_backend.settings')

app = Celery('tdesign_media_crawler_backend')

# 读取 Django 设置中的 Celery 配置
app.config_from_object('django.conf:settings', namespace='CELERY')

# 自动发现任务模块
app.autodiscover_tasks(lambda: [n.name for n in apps.get_app_configs()])


@app.task(bind=True)
def debug_task(self):
    print(f'Request: {self.request!r}')
